package org.vt.scheduleapp;

public class Loc{
	private String myName;
	private double myLat;
	private double myLon;
	public Loc(String n, double lat, double lon)
	{
		myName = n;
		myLat = lat;
		myLon = lon;
		
	}
	public String getName()
	{
		return myName;
	}
	public double getLat()
	{
		return myLat;
	}
	public double getLon()
	{
		return myLon;
	}
		
	public void setName(String newName)
	{
		myName=newName;
	}
	public void setLat(double newLat)
	{
		myLat=newLat;
	}
	public void setLon(double newLon)
	{
		myLon=newLon;
	}
		
	public String toString()
	{
		String out = "Name: " + myName.trim() + ", Latitude: " + myLat + ", Longitude: " + myLon;
		return out;
	}
	
	public int compare(Loc l)
	{
		int equality = 0;
		String tName = this.getName().trim();
		String lName = l.getName().trim();
		double tLat = this.getLat();
		double lLat = l.getLat();
		double tLon = this.getLon();
		double lLon = l.getLon();
		double latDiff = Math.abs(tLat-lLat);
		double lonDiff = Math.abs(tLon-lLon);
		double DiffMax = 00.0009;
		if(tName.equals(lName))
		{
			equality = equality+1;
		}
		if(latDiff<DiffMax&&lonDiff<DiffMax)
		{
			equality = equality+2;
		}
		return equality;
	}
}
